#ifndef _OD_GB28181_DB_H_
#define _OD_GB28181_DB_H_


#ifdef __cplusplus
    extern "C" {
#endif

typedef struct
{
    char DeviceID[64];            /**< like 3402000000111000001*/
    char Name[64];                /**< device name*/
    char Manufacturer[32];        /**< user Agent*/
    char Type[32];                /**< protocol type, GB28181 or GJB1.0*/
    char Password[32];            /**< only store in datebase*/
    char MediaTransport[32];      /**< udp, or tcp*/
    char MediaTransportMode[32];  /**< reserved*/
    char CommandTransport[32];    /**< udp, or tcp*/
    char RemoteIP[32];            /**< client ip addr*/
    int  RemotePort;              /**< client SIP src port*/
    int  Online;                  /**< online status, false or true*/
    int  ChannelCount;            /**< sub channel count*/
    char RecvStreamIP[32];        /**< reserved*/
    char ContactIP[32];           /**< sip header <contact>*/
    int  CatalogInterval;         /**< catalog refresh timeinterval*/
    int  SubscribeInterval;       /**< subscribe refresh time interval*/
    char LastRegisterAt[64];      /**< timestemp which server recv the last REGISTER signal*/
    char LastKeepaliveAt[64];     /**< timestemp which server recv heartbeat MESSAGE signal*/
    char CreateAt[64];            /**< get the first REGISTER, or the time when create this client in the server*/
    char UpdateAt[64];            /**< */
}od_sip_client_info;



#define DEVICE_INDEX_TAB   "DeviceIdx"
#define GB28181_DB_CREATE_DeviceIndex   "CREATE TABLE IF NOT EXISTS "DEVICE_INDEX_TAB" ("  \
                                        "ID INTEGER PRIMARY KEY     AUTOINCREMENT," \
                                        "DeviceID        TEXT       NOT NULL,"  \
                                        "Name            TEXT,"  \
                                        "Manufacturer    TEXT,"  \
                                        "Type            TEXT,"  \
                                        "Password        TEXT,"  \
                                        "MediaTransport  TEXT,"  \
                                        "MediaTransportMode  TEXT,"  \
                                        "CommandTransport  TEXT,"  \
                                        "RemoteIP  TEXT,"  \
                                        "RemotePort  INTEGER,"  \
                                        "Online  INTEGER,"  \
                                        "ChannelCount  INTEGER,"  \
                                        "RecvStreamIP  TEXT,"  \
                                        "ContactIP  TEXT,"  \
                                        "CatalogInterval  INTEGER,"  \
                                        "SubscribeInterval  INTEGER,"  \
                                        "LastRegisterAt  TEXT,"  \
                                        "LastKeepaliveAt  TEXT,"  \
                                        "CreateAt  TEXT,"  \
                                        "UpdateAt  TEXT);"  


#define GB28181_DB_GET_DEVIDX_INFO     "SELECT * FROM "DEVICE_INDEX_TAB" WHERE DeviceID LIKE '%s';"
#define GB28181_DB_DEL_DEVIDX_INFO     "DELETE FROM "DEVICE_INDEX_TAB" WHERE DeviceID LIKE '%s';"

#define GB28181_DB_INSERT_DEVIDX_INFO  "INSERT INTO "DEVICE_INDEX_TAB" (DeviceID, " \
                                                                    "Name,"  \
                                                                    "Manufacturer,"  \
                                                                    "Type,"  \
                                                                    "Password,"  \
                                                                    "MediaTransport,"  \
                                                                    "MediaTransportMode,"  \
                                                                    "CommandTransport,"  \
                                                                    "RemoteIP,"  \
                                                                    "RemotePort,"  \
                                                                    "Online,"  \
                                                                    "ChannelCount,"  \
                                                                    "RecvStreamIP,"  \
                                                                    "ContactIP,"  \
                                                                    "CatalogInterval,"  \
                                                                    "SubscribeInterval,"  \
                                                                    "LastRegisterAt,"  \
                                                                    "LastKeepaliveAt,"  \
                                                                    "CreateAt,"  \
                                                                    "UpdateAt) " \ 
                                                           "VALUES ( '%s', " \  /*DeviceID*/
                                                                   " '%s', " \  /*Name*/
                                                                   " '%s', " \  /*Manufacturer*/
                                                                   " '%s', " \  /*Type*/
                                                                   " '%s', " \  /*Password*/
                                                                   " '%s', " \  /*MediaTransport*/
                                                                   " '%s', " \  /*MediaTransportMode*/
                                                                   " '%s', " \  /*CommandTransport*/
                                                                   " '%s', " \  /*RemoteIP*/
                                                                   " %d,   " \  /*RemotePort*/
                                                                   " %d,   " \  /*Online*/
                                                                   " %d,   " \  /*ChannelCount*/
                                                                   " '%s', " \  /*RecvStreamIP*/
                                                                   " '%s', " \  /*ContactIP*/
                                                                   " %d,   " \  /*CatalogInterval*/
                                                                   " %d,   " \  /*SubscribeInterval*/
                                                                   " '%s', " \  /*LastRegisterAt*/
                                                                   " '%s', " \  /*LastKeepaliveAt*/
                                                                   " '%s', " \  /*CreateAt*/
                                                                   " '%s' );"   /*UpdateAt*/                      



#ifdef __cplusplus
    }
#endif


#endif


